﻿Public Class frmExibeRegistro
    Inherits formPadrao

    Private _num_registro As Integer
    Private _ano As Integer
    Private registro As New registroVO
    Private registroBO As New registroBO

    Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        Me.ControlBox = False
        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub


    Public Property NUM_REGISTRO As Integer
        Set(ByVal value As Integer)
            _num_registro = value
        End Set
        Get
            Return _num_registro
        End Get
    End Property

    Public Property ANO As Integer

        Set(ByVal value As Integer)
            _ano = value
        End Set
        Get
            Return _ano
        End Get
    End Property

    Private Sub frmExibeRegistro_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try

            registro = registroBO.getRegistro(_num_registro, _ano)

            If registro.GEROULAUDO Then
                lblMensagem.Visible = False
                btnVerWord.Visible = True
            Else
                lblMensagem.Text = "O registro nº" & registro.NUM_REGISTRO & " não possui laudo gerado automaticamente pelo sistema"
                lblMensagem.Visible = False
                btnVerWord.Visible = False

            End If

            With registro

                If IsNothing(.NUM_REGISTRO) Then
                    txtRegistro.Text = String.Empty
                Else
                    txtRegistro.Text = .NUM_REGISTRO
                End If

                If IsNothing(.DATA_REGISTRO) Then
                    txtDataReg.Text = String.Empty
                Else
                    txtDataReg.Text = .DATA_REGISTRO
                End If

                If IsNothing(.DATA_REQUISICAO_LAUDO) Then
                    txtDataEntrada.Text = String.Empty
                Else
                    txtDataEntrada.Text = .DATA_REQUISICAO_LAUDO
                End If


                If IsNothing(.DATA_CONCLUSAO_LAUDO) Then
                    txtConclusao.Text = String.Empty
                Else
                    txtConclusao.Text = .DATA_CONCLUSAO_LAUDO
                End If


                If IsNothing(.DATA_ACIONAMENTO) Then
                    txtAcionamento.Text = String.Empty
                Else
                    txtAcionamento.Text = .DATA_ACIONAMENTO
                End If
                If IsNothing(.DATA_ENTREGA_LAUDO) Then
                    txtEntrega.Text = String.Empty
                Else
                    txtEntrega.Text = .DATA_ENTREGA_LAUDO
                End If

                If IsNothing(.DATA_PRAZO_LAUDO) Then
                    txtPrazo.Text = String.Empty
                Else
                    txtPrazo.Text = .DATA_PRAZO_LAUDO
                End If


                If IsNothing(.NATUREZA.DESC_NATUREZA) Then
                    txtNatureza.Text = String.Empty
                Else
                    txtNatureza.Text = .NATUREZA.DESC_NATUREZA
                End If


                If IsNothing(.ENDERECO) Then
                    txtEndereco.Text = String.Empty
                Else
                    txtEndereco.Text = .ENDERECO
                End If

                If IsNothing(.INVESTIGADO) Then
                    txtInvestigado.Text = String.Empty
                Else
                    txtInvestigado.Text = .INVESTIGADO
                End If

                If IsNothing(.VITIMA) Then
                    txtVitima.Text = String.Empty
                Else
                    txtVitima.Text = .VITIMA
                End If

                If IsNothing(.PROVAS) Then
                    txtProva.Text = String.Empty
                Else
                    txtProva.Text = .PROVAS
                End If

                If IsNothing(.OBSERVACAO) Then
                    txtObs.Text = String.Empty
                Else
                    txtObs.Text = .OBSERVACAO
                End If

                If IsNothing(.MUNICIPIO.DESC_MUNICIPIO) Then
                    txtDestino.Text = String.Empty
                Else
                    txtDestino.Text = .MUNICIPIO.DESC_MUNICIPIO
                End If

                'If IsNothing(.DESTINO.DESC_DESTINO) Then
                '    txtDestino.Text = String.Empty
                'Else
                '    txtDestino.Text = .DESTINO.DESC_DESTINO
                'End If

                If IsNothing(.USUARIO.NOME) Then
                    txtPerito.Text = String.Empty
                Else
                    txtPerito.Text = .USUARIO.NOME
                End If

                If .GEROULAUDO Then
                    chkAutomatico.Checked = True
                Else
                    chkAutomatico.Checked = False
                End If
            End With
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub btnSair_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSair.Click
        Me.Close()
    End Sub

    Private Sub btnVerWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVerWord.Click
        Try
            generica.visualizaWord("", "", registro.NOME_DIRETORIO)
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub
End Class